#!/bin/bash

CUR_DIR="$( cd "$( dirname "$(readlink -f "$0")" )" && pwd )"

source $CUR_DIR/../cluster_IP.conf

ORG_ID=0 # bc-storage cluster org id, which is globally unique, like 0-3

help() {
    echo "Usage:"
    echo "    ./down_ceph.sh -i <org_id>"
    echo "        -i, --org_id: bc-storage cluster org id, which is globally unique, like 0-3"
}

if [ $# -gt 3 ]; then
    help
    exit -1
fi

while [ $# -ge 1 ]; do
case $1 in
    -i | --org_id)
        [ -z "$2" ] && help
        ORG_ID=$2
        shift
        ;;
    *)
        help
        exit -1
esac
shift
done

CEPH_NAME="ceph-demo-$ORG_ID"
CEPH_SRC_DIR="$HOME/ssd/build-ceph/"

down_ceph() {
    cd $CUR_DIR
    docker exec $CEPH_NAME zsh -c "
        cd /home/czy/ssd/build-ceph/$CEPH_NAME/build && \
        ../src/stop.sh && \
        rm -rf out dev
    "
}

down_ceph